<%--
  Created by IntelliJ IDEA.
  User: 70481
  Date: 2019/9/22
  Time: 14:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>审核管理</title>
    <link href="layui/css/layui.css" rel="stylesheet" type="text/css">
</head>
<body>
<table id="myTable" lay-filter="myTable"></table>

<form class="layui-form layui-form-pane" action="" style="display: none" id="myForm" lay-filter="myForm">
    <input type="hidden" name="examId" value="" id="examId">
    <div class="layui-form-item">
        <div class="layui-inline" style="width: 385px">
            <label class="layui-form-label">药品名</label>
            <div class="layui-input-block">
                <input type="text" name="drugDrugName" autocomplete="off" lay-verify="required" placeholder="药品名" class="layui-input">
            </div>
        </div>
        <div class="layui-inline" style="width: 385px">
            <label class="layui-form-label">厂商</label>
            <div class="layui-input-block">
                <input type="text" name="drugDrugProductCompany" autocomplete="off" lay-verify="required" placeholder="规格" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item" pane="">
            <label class="layui-form-label">审核意见</label>
            <div class="layui-input-inline">
                <input type="radio" name="examStatus" value="2" title="通过" >
                <input type="radio" name="examStatus" value="3" title="不予通过">
            </div>

    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">审核意见 </label>
        <div class="layui-input-block">
            <textarea name="examAdvice" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="update">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>


<form class="layui-form layui-form-pane" action="" style="display: none" id="myFormLook" lay-filter="myFormLook">
    <input type="hidden" name="drugId" value="" id="drugId">
    <div class="layui-form-item">
        <div class="layui-inline" style="width: 385px">
            <label class="layui-form-label">药品名</label>
            <div class="layui-input-block">
                <input type="text" readonly name="drugName" autocomplete="off" lay-verify="required" placeholder="药品名" class="layui-input">
            </div>
        </div>
        <div class="layui-inline" style="width: 385px">
            <label class="layui-form-label">规格</label>
            <div class="layui-input-block">
                <input type="text" readonly name="drugSpec" autocomplete="off" lay-verify="required" placeholder="规格" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline" style="width: 385px">
            <label class="layui-form-label">单位</label>
            <div class="layui-input-block">
                <input type="text" readonly name="drugUnit" lay-verify="required" placeholder="单位" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline" style="width: 385px">
            <label class="layui-form-label">生产企业</label>
            <div class="layui-input-block">
                <input type="text" readonly name="drugProductCompany" lay-verify="required" placeholder="生产企业" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline" style="width: 385px">
            <label class="layui-form-label">生产日期</label>
            <div class="layui-input-block">
                <input type="text" readonly name="drugProductDate" id="date1" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline" style="width: 385px">
            <label class="layui-form-label">保质期至</label>
            <div class="layui-input-block">
                <input type="text" readonly name="drugOKDate" id="date2" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline" style="width: 385px">
            <label class="layui-form-label">进价</label>
            <div class="layui-input-block">
                <input type="text" readonly name="drugImportPrice" lay-verify="required" placeholder="进价" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline" style="width: 385px">
            <label class="layui-form-label">零售价</label>
            <div class="layui-input-block">
                <input type="text" readonly name="drugPrice" lay-verify="required" placeholder="零售价" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>



    <div class="layui-form-item" pane="">
        <div class="layui-inline" style="width: 385px">
            <label class="layui-form-label">销售状态</label>
            <div class="layui-input-inline">
                <input type="radio" name="drugSaleStatus" value="0" title="是" disabled>
                <input type="radio" name="drugSaleStatus" value="1" title="否" disabled>
            </div>
        </div>

        <div class="layui-inline" style="width: 385px">
            <label class="layui-form-label">是否进口</label>
            <div class="layui-input-inline">
                <input type="radio" name="drugIsImport" value="0" title="是" disabled>
                <input type="radio" name="drugIsImport" value="1" title="否" disabled>
            </div>
        </div>

    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">产品说明 </label>
        <div class="layui-input-block">
            <textarea name="drugDescription" placeholder="请输入内容" class="layui-textarea" readonly></textarea>
        </div>
    </div>
</form>

</body>
<script type="text/javascript" src="${pageContext.request.contextPath}/layui/layui.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.12.4.js"></script>

<script type="text/javascript">
    layui.use(["table","form","layer","laydate"],function () {
        var laydate = layui.laydate;
        var table = layui.table;
        var form = layui.form;
        var layer = layui.layer;
        // 初始化表单
        // 初始化表格
        table.render({
            elem: '#myTable'
            ,url: '${pageContext.request.contextPath}/exam/selectExamPage' //数据接口
            ,page: true //开启分页
            ,toolbar:"#toolHead"
            ,defaultToolbar:[]
            ,cols: [[ //表头
                {checkbox:"checkbox"},
                {field: 'examId', title: '编号',width:150}
                ,{field: 'drugName', title: '药品名',width:150,templet:"#drugName"}
                ,{field: 'drug', title: '生产企业',templet:"#drugProductCompany"}
                ,{field: 'examStartDate', title: '开始时间'}
                ,{field: 'examEndDate', title: '结束时间'}
                ,{field: 'examStatus', title: '审核状态',width:110,templet:"#status"}
                ,{toolbar:"#operation", title: '操作',align:'center'}
            ]]
        })
        // 头监听
        table.on("toolbar(myTable)",function (data) {
            table.reload("myTable",{
                where:{"name":$("#name").val()}
            })
        })
        // 行监听
        table.on("tool(myTable)",function (obj) {
            var params = obj.data;
            console.log(params)
            // alert(23)
            switch(obj.event){
                case "look":
                    // 查看详情 ？？ 看什么？
                    form.val("myFormLook",{
                        drugId:params.drug.drugId,
                        drugName:params.drug.drugName,
                        drugSpec:params.drug.drugSpec,
                        drugUnit:params.drug.drugUnit,
                        drugProductCompany:params.drug.drugProductCompany,
                        drugProductDate:params.drug.drugProductDate,
                        drugOKDate:params.drug.drugOKDate,
                        drugImportPrice:params.drug.drugImportPrice,
                        drugPrice:params.drug.drugPrice,
                        drugSaleStatus:params.drug.drugSaleStatus,
                        drugIsImport:params.drug.drugIsImport,
                        drugDescription:params.drug.drugDescription
                    });
                    layer.open({
                        type:"1",
                        title:"药品详情",
                        offset:"t",
                        anim:"1",
                        area:["100%","100%"],
                        content:$("#myFormLook")
                    });

                break;
                case "examine":
                    // 审核
                    form.val("myForm",{
                        examId:params.examId,
                        drugDrugName:params.drug.drugName,
                        drugDrugProductCompany:params.drug.drugProductCompany,
                        examAdvice:params.examAdvice
                    })

                    layer.open({
                        type:"1",
                        title:"药品审核",
                        offset:"t",
                        anim:"1",
                        area:"800px",
                        content:$("#myForm")
                    });
                break;
            }
        })

        // form监听
        form.on("submit(update)",function (data) {
            $.ajax({
                url:"${pageContext.request.contextPath}/exam/updateExam",
                type:"post",
                data:data.field,
                success:function(data){
                    layer.msg(data.isSuccess,{time:1250})
                    layer.closeAll("page");
                    table.reload("myTable");
                }
            });
            return false;
        })
    })
</script>

<script type="text/html" id="status">
    {{#  if(d.examStatus == 0){ }}
    未审核
    {{#  }else if(d.examStatus == 1){ }}
    审核中
    {{#  }else if(d.examStatus == 2){ }}
    审核通过
    {{#  } else { }}
   审核未通过
    {{#  } }}
</script>
<script type="text/html" id="drugProductCompany">
    {{d.drug.drugProductCompany}}
</script>
<script type="text/html" id="drugName">
   {{d.drug.drugName}}
</script>
<script type="text/html" id="operation">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="look">
        <i class="layui-icon layui-icon-delete"></i>查看详情
    </a>

    <a class="layui-btn  layui-btn-xs" lay-event="examine">
        <i class="layui-icon layui-icon-vercode"></i>审核
    </a>

</script>



<script type="text/html" id="toolHead">

    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="text" name="drugName" id="name" value="" placeholder="请输入药品关键字">
    <a class="layui-btn layui-btn-radius layui-btn-normal layui-btn-xs" lay-event="search">
        <i class="layui-icon layui-icon-search"></i>搜索
    </a>
</script>

    
</html>
